//
//  UserAPI.swift
//  JLDiaryApp
//
//  Created by Jiang Chencheng on 2024/9/24.
//

import Foundation
import Moya

enum UserService {
    case signup(email: String, password: String)
    case signin(email: String, password: String)
}

// MARK: - TargetType Protocol Implementation
extension UserService: JLTargetType {
    
    var path: String {
        switch self {
        case .signup:
            return "/signup"
        case .signin:
            return "/signin"
        }
    }
    
    var method: Moya.Method {
        switch self {
        case .signup, .signin:
            return .post
        
        }
    }
    
    var task: Task {
        switch self {
        case .signup(let email, let password):
            return .requestParameters(parameters: ["email": email, "password": password], encoding: JSONEncoding.default)
            
        case .signin(let email, let password):
            return .requestParameters(parameters: ["email": email, "password": password], encoding: JSONEncoding.default)
        
        }
    }

}
